//
//  HomeBottomRightView.swift
//  ExtremeHealth
//
//  Created by Zhongkai Li 李忠凯 on 2018/9/29.
//  Copyright © 2018 GanDongKeJi. All rights reserved.
//

import SwiftFontName

class HomeBottomRightView: HomeCardView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        titleLabel.text = "情绪"
        setUpViews()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private func setUpViews() {
        let imageView = UIImageView()
        imageView.image = UIImage(named: "icon_calm")
        imageView.translatesAutoresizingMaskIntoConstraints = false
        addSubview(imageView)
        NSLayoutConstraint.activate([
            imageView.centerXAnchor.constraint(equalTo: centerXAnchor),
            imageView.widthAnchor.constraint(equalToConstant: 48),
            imageView.heightAnchor.constraint(equalToConstant: 48),
            NSLayoutConstraint(item: imageView, attribute: .centerY, relatedBy: .equal,
                               toItem: self, attribute: .centerY, multiplier: 0.9, constant: 0)
            ])

        let descLabel = UILabel()
        descLabel.text = "12:30 悲伤"
        descLabel.font = UIFont(name: FontName.PingFangSCLight, size: 12)
        descLabel.textColor = UIColor("#333333")
        descLabel.translatesAutoresizingMaskIntoConstraints = false
        addSubview(descLabel)
        NSLayoutConstraint.activate([
            descLabel.centerXAnchor.constraint(equalTo: centerXAnchor),
            NSLayoutConstraint(item: descLabel, attribute: .centerY, relatedBy: .equal,
                               toItem: self, attribute: .centerY, multiplier: 1.4, constant: 0)
            ])

        let cameraButton = UIButton(type: .custom)
        cameraButton.setImage(UIImage(named: "icon_camera"), for: .normal)
        cameraButton.translatesAutoresizingMaskIntoConstraints = false
        addSubview(cameraButton)
        NSLayoutConstraint.activate([
            cameraButton.centerXAnchor.constraint(equalTo: centerXAnchor),
            NSLayoutConstraint(item: cameraButton, attribute: .centerY, relatedBy: .equal,
                               toItem: self, attribute: .centerY, multiplier: 1.7, constant: 0)
            ])
    }
}
